/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package general.util;

import jpa.controller.UserJpaController;
import jpa.entity.User;

/**
 *
 * @author isaias
 */
public class MyGeneralUtil {



    public static User login(String login, String password) {
        if (login != null && password != null) {

            User realUser = new UserJpaController().findUserByLogin(login, true);
            if (realUser != null) {
                if (MyStringUtil.isNullOrEmpty(realUser.getPassword())) {
                    realUser.setPassword(MySecurityUtil.md5("123456"));
                }
            }

            if (realUser != null && realUser.getPassword().equals(password)) {
                return realUser;
            }

        }

        return null;
    }

}
